<template>
<div>
  <el-form :inline="true" :model="user" class="demo-form-inline">
    <el-form-item label="账号">
      <el-input v-model="user.username" placeholder="账号"></el-input>
    </el-form-item><br>
    <el-form-item label="密码">
      <el-input type="password" v-model="user.password" placeholder="密码"></el-input>
    </el-form-item><br>
    <el-form-item>
      <el-button type="primary" @click="login">登录</el-button>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return{
      user:{}
    }
  },
  created() {
  },
  methods:{
    login() {
      this.axios.post("http://localhost:81/user/login",this.user).then(
          res=>{
            if (res.data.code === 200) {
              this.$message.success("登录成功");
             localStorage.setItem("token",res.data.data)
              this.$router.push("/list")
            } else {
              this.$message.error("登录失败")
            }
          }
      )
    }
  }
}
</script>

<style scoped>

</style>
